using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class MyGUIToggle : GUIControl
{
    public bool isSel;
    public event UnityAction<bool> ChangeValue;
    private bool oldIsSel;
    protected override void StyleOffDraw()
    {
        isSel = GUI.Toggle(guiPos.Pos, isSel, content);
        //只有变化时 才告诉外部 执行函数
        if (oldIsSel != isSel)
        {
            ChangeValue?.Invoke(isSel);
            oldIsSel = isSel;
        }
    }

    protected override void StyleOnDraw()
    {
        isSel = GUI.Toggle(guiPos.Pos, isSel, content, style);
        if (oldIsSel != isSel)
        {
            ChangeValue?.Invoke(isSel);
            oldIsSel = isSel;
        }
    }
}
